/*
 * CVTVT.H
 *
 * Convert VT100/ANSI escape sequences into HTML, native Win32 console or
 * remove them completely.
 *
 * Copyright (c) 2015 Malcolm J. Smith
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

#define WIN32_LEAN_AND_MEAN 1
#define _CRT_SECURE_NO_WARNINGS 1
#define _CRT_NONSTDC_NO_WARNINGS 1
#include <windows.h>

#include <stdlib.h>
#include <stdio.h>

#ifdef MINICRT
#include <minicrt.h>
#endif

#ifndef sprintf_s
#define sprintf_s _snprintf
#endif

#ifndef FILE_SHARE_DELETE
#define FILE_SHARE_DELETE 4
#endif

#ifndef COMMON_LVB_UNDERSCORE
#define COMMON_LVB_UNDERSCORE 0x8000
#endif

typedef BOOL (* INITIALIZE_STREAM_FN)(HANDLE, HANDLE);
typedef BOOL (* END_STREAM_FN)(HANDLE, HANDLE);
typedef BOOL (* PROCESS_AND_OUTPUT_TEXT_FN)(HANDLE, HANDLE, LPSTR, ULONG);
typedef BOOL (* PROCESS_AND_OUTPUT_ESCAPE_FN)(HANDLE, HANDLE, LPSTR, ULONG);

typedef struct _CALLBACK_FUNCTIONS {
    INITIALIZE_STREAM_FN InitializeStream;
    END_STREAM_FN EndStream;
    PROCESS_AND_OUTPUT_TEXT_FN ProcessAndOutputText;
    PROCESS_AND_OUTPUT_ESCAPE_FN ProcessAndOutputEscape;
} CALLBACK_FUNCTIONS, *PCALLBACK_FUNCTIONS;

extern int memspn(CHAR * str, ULONG length, CHAR * chars);
extern int memcspn(CHAR * str, ULONG length, CHAR * match);

extern BOOL Html4SetFunctions(PCALLBACK_FUNCTIONS CallbackFunctions);
extern BOOL Html5SetFunctions(PCALLBACK_FUNCTIONS CallbackFunctions);
extern BOOL Win32SetFunctions(PCALLBACK_FUNCTIONS CallbackFunctions);
extern BOOL TextSetFunctions(PCALLBACK_FUNCTIONS CallbackFunctions);

extern int memspn(CHAR * str, ULONG length, CHAR * chars);
extern int memtoi(CHAR * str, ULONG length);

// vim:sw=4:ts=4:et:
